<template>
  <div>
    <van-form ref="form">
      <van-cell-group>
        <van-field
          v-model="loginForm.userAccount"
          clearable
          placeholder="请输入帐号/邮箱/手机号"
          :rules="[
						{ required: true, message: '账号不能为空' }
						]"
          :focus="true"
        />
        <van-field
          v-model="loginForm.userPassword"
          type="password"
          placeholder="请输入密码"
          clearable
          :rules="[
						{ required: true, message: '密码不能为空' }
						]"
        />

        <van-field
          v-model="loginForm.valicode"
          clearable
          :rules="[{required:true,message:'验证码不能为空'}]"
          placeholder="请输入验证码"
        >
          <template #button>
            <van-button size="small" type="primary">发送验证码</van-button>
          </template>
        </van-field>
        <van-button style="margin-top: 20px" type="primary" @click="submit" block>登录</van-button>
      </van-cell-group>
    </van-form>
  </div>
</template>

<script>
import { login } from "@/net/apis/goUser.js";
export default {
  name: "login",
  data() {
    return {
      loginForm: {
        userAccount: "",
        userPassword: "",
        valicode: ""
      }
    };
  },
  methods: {
    async submit() {
      const isNull =
        this.loginForm.userAccount === "" ||
        this.loginForm.userPassword === "" ||
        this.loginForm.valicode === "";
      if (isNull) return;
      const result = await login(this.loginForm);
    }
  }
};
</script>

<style scope>
.van-field {
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}
</style>
